<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>my</title>
    <script>
        function showTime() {
            var date = new Date();
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var day = date.getDate();
            var hour = date.getHours();
            var minute = date.getMinutes();
            var second = date.getSeconds();
            var timeStr = year + "年" + month + "月" + day + "日" + " " + hour + ":" + minute + ":" + second;
            document.getElementById("time").innerHTML = timeStr;
            setTimeout("showTime()", 1000);
        } 
    </script>
</head>
<body>
    <p>当前时间是: <span id="time"></span></p>
    <script>
        showTime();
    </script>
    <script>
        var none ="";
        var a = prompt("请输入层数：");
        a=parseInt(a);
        for (var i = 1; i <= a; i++) {
            for (var l = 1; l <=a-i; l++) {
                none +=" ";
            }
            for (var j = 1; j <= i*2-1; j++) {
               none += "*";
            }
            none += "\n";
        }
        window.alert(none);
    </script>
</body>
</html>